onload = function() {

  var myScroll = new IScroll("#homepageBody", {
    probeType: 3,
    mouseWheel: true
  })

  var mySwiper = new Swiper('#swiper-container1', {
    autoplay: 5000, //可选选项，自动滑动
    pagination: '.swiper-pagination',
    loop: true
  })

  var mySwiperQuickList = new Swiper('#swiper-container2', {
    autoplay: 5000, //可选选项，自动滑动
    loop: true,
    slidesPerView: 'auto'
  })

  var ItemList=[];

  $.ajax({
    url: '/api/ststic',
    data: {
      topicId: 1165
    },
    success: function(res) {
      var resObject = JSON.parse(res)
      var dataSource = resObject
      ItemList = ItemList.concat(dataSource.hashMapList)
      var list = template('indexList', {hashMapList: ItemList})
      $('#homepageList ul').html(list)
      myScroll.refresh();
    }
  })
  var foot = $('.homePageFooter img');
  myScroll.on('scroll', function () {
    var y = this.y,
        maxY = this.maxScrollY - y;
    if (maxY >= 0) {
       foot.addClass('down');
      return '';
    }
  });

  myScroll.on('scrollEnd', function () {
    var y = this.y,
    maxY = this.maxScrollY - y;
    if (maxY >= 0) {
      $('.homePageFooter img').attr('src', '../images/ajax-loader.gif');
      $.ajax({
        url: '/api',
        data: {
          topicId: 1165
        },
        success: function(res) {

          $('.homePageFooter img').removeClass('up');
          $('.homePageFooter img').attr('src', '../images/arrow.png');


          var resObject = JSON.parse(res)
          var dataSource = resObject
          ItemList = ItemList.concat(dataSource.hashMapList)
          var list = template('indexList', {hashMapList: ItemList})
          $('#homepageList ul').html(list)
          myScroll.refresh();
        }
      })
    }
  })

  //other link tap
  $('#JXCategoryTab').click(function() {
    window.open("./categorypage.html", '_self')
  })

  $('#JXActivityTab').click(function() {
    window.open("./activityPage.html", '_self')
  })

  $('#JXShopChartTab').click(function() {
    window.open("./shopChart.html", '_self')
  })

  $('#JXUserCenterTab').click(function() {
    window.open("./loginPage.html", '_self')
  })


  // document.addEventListener("touchmove", function(event) {
  //   var e = event||window.event;
  //   console.log(123)
  //   e.preventDefault();
  // }, {passive:false});

}
